const gulp = require("gulp");

// 转译Javascript
gulp.task("webpack", () => {
	const webpack = require("webpack-stream");
	const config = require("./webpack.config.js");
	return gulp.src("src/js/**/*.js")
			.pipe(webpack(config))
			.pipe(gulp.dest("./www/js"))
});

// 编译less -> css
gulp.task("less", () => {
	const less = require("gulp-less");
	return gulp.src("src/less/*.less")
			.pipe(less())
			.pipe(gulp.dest("./www/css"));
})

gulp.task("default", gulp.parallel("webpack", "less"));

gulp.task("watch", () => {
    gulp.watch("src/less/**/*.less", gulp.series("less"));
    gulp.watch("src/js/**/*.js", gulp.series("webpack"));
});